// pages/module/litileHelper/litileHelper.js

var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    btn_list:[
      {"id":1,"name":"全部","low":"",'high':'',"is_selected":1},
      {"id":2,"name":"0-20","low":"0",'high':'0.2',"is_selected":0},
      {"id":3,"name":"21-40","low":"0.2",'high':'0.4',"is_selected":0},
      {"id":4,"name":"41-60","low":"0.4",'high':'0.6',"is_selected":0},
      {"id":3,"name":"61-80","low":"0.6",'high':'0.8',"is_selected":0},
      {"id":4,"name":"81-100","low":"0.8",'high':'1',"is_selected":0},
    ],
    title:'激活小助手',
    tagsList:[],
    input_value:'',
    
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      title:'激活小助手'
    })
  },


  
  toggleShow3(e) {
    this.type = e.currentTarget.dataset.type;
		this.setData({
			timeShow3: true
		});
	},
  timeSelect3(e) {
    let {date, dateTimeStr} = e.detail;
    if(this.type == 'start'){
      this.setData({
        time3: date.getTime(),
        timeStr3: dateTimeStr
      });
    } else {
      this.setData({
        time4: date.getTime(),
        timeStr4: dateTimeStr
      });
    }
  },
  chooseFromEarn(e){
    var index = e.currentTarget.dataset.index;
    this.data.btn_list.forEach(element => {
      element.is_selected = 0
    });
    this.data.btn_list[index].is_selected = 1
    this.setData({
      btn_index:index,
      btn_list: this.data.btn_list
    })
  },
  showPart(){
    this.setData({
      show_part:true,
    })
  },
  hideShare(){
    this.setData({
      show_part:false,
    })
  },
  changeInput(e){
    this.data.input_value = e.detail.value;
  },
  deleteItem(e){
    var index = e.currentTarget.dataset.index;
    this.data.tagsList.splice(index,1)
    this.setData({
      tagsList:this.data.tagsList
    })
  },
  confirm(){
    if(!this.data.input_value){
      wx.showToast({
        icon:'none',
        title: '请输入关键词',
      })
      return;
    }
    if(this.data.tagsList.indexOf(this.data.input_value)>-1){
      wx.showToast({
        icon:'none',
        title: '已存在该关键词，请重新输入',
      })
      return;
    }
    this.data.tagsList.push(this.data.input_value);
    this.setData({
      tagsList:this.data.tagsList,
      show_part:false,
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
   
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})